<?php

function update_option($key, $value) {
    global $aldb;
    switch ($key) {
        case 'active_plugins':
            $value = serialize($value);
            break;
        case 'site_url':
        case 'home_url':
            $value = rtrim($value, '/');
            break;
    }
    $aldb->query("UPDATE `$aldb->options` SET `option_value` = '$value' WHERE `option_name`='$key' LIMIT 1");
    return true;
}

function update_cache_config($time = 600, $status = false) {
    # Write the cache config
    $handle = fopen(ARLICLE_WWW . 'config/cache.php', 'w');
    $content = "<?php
// ** Cache settings ** //
define('CACHE', $status); # enable or off the cache
define('CACHE_PATH', TMP_PATH . 'cache/'); # set the cache path
define('CACHE_TIMEOUT', $time); # set the cache timeout

?>";
    fwrite($handle, $content);
    fclose($handle);
}
?>
